package com.ignoreexception.exception;

import com.ignoreexception.bean.vo.BaseRespVo;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RestControllerAdvice;

/**
 * 对handler方法增强
 * 异常增强,
 * @author xD
 * @since 2022/12/26 19:53
 */
@RestControllerAdvice
public class CustomExceptionControllerAdvice {
//    @ExceptionHandler(ArithmeticException.class)
//    public ModelAndView resolveArithmeticException(ModelAndView modelAndView){
//        modelAndView.setViewName("/exception.jsp");
//        return modelAndView;
//    }


    //    @ExceptionHandler(ArithmeticException.class)
//    public String resolveArithmeticException() {
//        return "/exception.jsp";
//    }
    @ExceptionHandler(ArithmeticException.class)
    public BaseRespVo resolveArithmeticException(ArithmeticException exception) {
        String message = exception.getMessage();
        return BaseRespVo.error("算数异常!" + message);
    }

}
